package com.ma;

import com.ma.sort.heapSort;

import java.util.Arrays;
import java.util.PriorityQueue;

import static com.ma.tool.logarithm.randomArray.copyArray;
import static com.ma.tool.logarithm.randomArray.getRandomArray;
import static com.ma.tool.system.basics.comparator;
import static com.ma.tool.system.basics.isEqual;

public class heapSortTest {
    public static void main(String[] args) {
        Test1(50000,5000,5000);

    }
    public static void Test1(int maxTime, int maxValue, int maxSize){
        int n=0;
        for(int i=0;i<maxTime;i++){
            int[] arr1 = getRandomArray(maxSize, maxValue);
            int[] arr2 = copyArray(arr1);
            int[] arr3 = copyArray(arr1);
            heapSort.run(arr1);
            comparator(arr2);
            if (!isEqual(arr1,arr2)) {
                n++;
                System.out.println("i:"+i+"第" + n + "次失败用例:");
                System.out.println(Arrays.toString(arr1));
                System.out.println(Arrays.toString(arr2));
                System.out.println(Arrays.toString(arr3));

                break;
            }
            if (n > 0) {
                System.out.println("共失败次数:" + n);
            }
        }
        if (n == 0) {
            System.out.println("恭喜没有失败用例!");
        }
    }
    public static void Test2(int maxTime, int maxValue, int maxSize,int k){
        int n=0;
        for(int i=0;i<maxTime;i++){
            int[] arr1 = getRandomArray(maxSize, maxValue);
            int[] arr2 = copyArray(arr1);
            int[] arr3 = copyArray(arr1);
            heapSort.partiallyOrdered(arr1,k);
            if (!isEqual(arr1,arr2)) {
                n++;
                System.out.println("i:"+i+"第" + n + "次失败用例:");
                System.out.println(Arrays.toString(arr1));
                System.out.println(Arrays.toString(arr2));
                System.out.println(Arrays.toString(arr3));

                break;
            }
            if (n > 0) {
                System.out.println("共失败次数:" + n);
            }
        }
        if (n == 0) {
            System.out.println("恭喜没有失败用例!");
        }
    }


}
